package script.db.groovy.workflow_service

/**
 * 班翎工作流升级sql
 * @author gaokuo.dai@zknow.com 2022-08-07
 **/
databaseChangeLog(logicalFilePath: 'script/db/z_cwkf_data_fix.groovy') {

    // ↓↓↓↓ hwkf 1.7 - 1.8 ↓↓↓↓
    changeSet(id: '2022-08-07-cwkf-data-fix-update-hwkf-1.8-001', author: 'gaokuo.dai@zknow.com') {
        sql(stripComments: true, splitStatements: false, endDelimiter: ';') {
            // lov更新
            "DELETE FROM hpfm_lov_view_line WHERE view_header_id = (\n" +
                    "SELECT view_header_id FROM hpfm_lov_view_header WHERE view_code = 'HWKF.VARIABLE' AND tenant_id = 0\n" +
                    ")\n" +
                    "AND field_name = 'sourceType'"
        }
    }
    changeSet(id: '2022-08-07-cwkf-data-fix-update-hwkf-1.8-002', author: 'gaokuo.dai@zknow.com') {
        sql(stripComments: true, splitStatements: false, endDelimiter: ';') {
            // lov更新
            "DELETE FROM hpfm_lov_view_line WHERE view_header_id = (\n" +
                    "SELECT view_header_id FROM hpfm_lov_view_header WHERE view_code = 'HWKF.EVENT_RESULT_PARAM' AND tenant_id = 0\n" +
                    ")\n" +
                    "AND field_name = 'variableType'"
        }
    }

    // ↓↓↓↓ hwkf 1.8 - 1.9 ↓↓↓↓
    changeSet(id: '2022-08-07-cwkf-data-fix-update-hwkf-1.9-001', author: 'gaokuo.dai@zknow.com') {
        sql(stripComments: true, splitStatements: false, endDelimiter: ';') {
            // lov更新
            "DELETE FROM hzero_platform.hpfm_lov_value where LOV_CODE = 'HWKF.ATTRIBUTE.TYPE' AND VALUE IN ('TEXTBOX','CHECKBOX','DROPDOWNLIST','TIMEFRAME','DATEBOX')"
        }
    }

    // ↓↓↓↓ hwkf 1.10 - 1.11 ↓↓↓↓
    changeSet(id: '2022-08-07-cwkf-data-fix-update-hwkf-1.11-001', author: 'gaokuo.dai@zknow.com') {

        sql(stripComments: true, splitStatements: false, endDelimiter: ';') {
            // lov更新
            "DELETE FROM HZERO_PLATFORM.HPFM_LOV_VALUE WHERE LOV_CODE = 'HWKF.APPROVE_ACTION' AND VALUE = 'ADD_NODE_APPROVER'"
        }
    }
}
